package com.workflow.workflowproject.serviceImpl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.workflow.workflowproject.entity.FlowVersion;
import com.workflow.workflowproject.mapper.FlowVersionMapper;
import com.workflow.workflowproject.service.FlowVersionService;
import com.workflow.workflowproject.tools.Result.Result;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class FlowVersionServiceImpl extends ServiceImpl<FlowVersionMapper, FlowVersion> implements FlowVersionService {
    /**
     * 添加流程版本信息
     *
     * @param
     * @return
     */
    @Override
    public Result addFlowVersion(FlowVersion flowVersion) throws Exception {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年mm月dd日 HH时mm分ss秒");
        flowVersion.setName(simpleDateFormat.format(new Date()));
        flowVersion.setState(0);
        if(this.getMapper().insert(flowVersion) == 0){
            return Result.fail("添加流程版本信息失败");
        }
        return Result.ok(flowVersion);
    }

    @Override
    public Result getAllFlowVersion(Integer flowInfoId) throws Exception {
        return null;
    }
}
